package com.yiren.dbaa.module.exam.model;

import android.app.Activity;

import com.yiren.dbaa.currency.api.CommonCallBack;
import com.yiren.dbaa.module.exam.contract.ExamStudentContract;
import com.yiren.dbaa.net.bean.StudentBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Describe
 *
 * @author WRX
 * @date 2022/7/15
 */
public class ExamStudentModel implements ExamStudentContract.Model {

    private Activity activity;

    public ExamStudentModel(Activity activity) {
        this.activity = activity;
    }

    @Override
    public void sortStudentList(List<StudentBean> studentBeans, StudentBean student, CommonCallBack callBack) {
        List<StudentBean> students = new ArrayList<>();
        if (null != studentBeans) {
            if (null != student) {
                for (int i = 0; i < studentBeans.size(); i++) {
                    if (student.getStudent().equals(studentBeans.get(i).getStudent())) {
                        students.add(0, studentBeans.get(i));
                    } else {
                        students.add(studentBeans.get(i));
                    }
                }
            } else {
                students.addAll(studentBeans);
            }
        }
        callBack.success(students);
    }
}
